<%@ include file="/WEB-INF/views/jsp/include/include.jsp"%>
<html>
<head>
<title>Hand In Hand</title>
<%@ include file="/WEB-INF/views/jsp/include/head.jsp"%>
</head>
<body>
	<%@ include file="/WEB-INF/views/jsp/include/header.jsp"%>
	<%@ include file="/WEB-INF/views/jsp/include/navigator.jsp"%>

	<div class="container-fluid">
	
		<!-- Public Profile (Left Column) -->
		<div id="leftColumn" class="col-xs-3">
			<div class="col-xs-8 col-xs-offset-4"> <!-- border -->
				<c:if test="${profileViewForm.profileOwner.picture != null }" >
				<img src="<c:url value="/picture"/>" class="img-rounded"/>
				</c:if>
			    <c:if test="${profileViewForm.profileOwner.picture == null }" >
					<img src=<c:url value="/resources/images/maleicon.jpg"/>
					class="img-rounded">
				</c:if>
				<strong class="col-xs-10 col-xs-offset-1"><c:out value="${profileViewForm.profileOwner.name} ${profileViewForm.profileOwner.surname}"></c:out></strong>
		</div>
		</div>
		<div id="center" class="col-xs-6">
<!-- 			<label>Name:</label> -->
			<h2> ${profileViewForm.profileOwner.name} ${profileViewForm.profileOwner.surname} </h2><br>
<%-- 			<span style="font-size: 1.0em; height: 30px; overflow-wrap:break-word;">${profileViewForm.profileOwner.name}</span><br> --%>
				<c:if test="${profileViewForm.profileOwner.id == profileViewForm.profileViewer.id ||
								profileViewForm.profileOwner.userPrivacy == 'PUBLIC' ||
								profileViewForm.friendship != null}">
				<c:if test="${profileViewForm.profileOwner.city != null && profileViewForm.profileOwner.city != ''}">
					<label>City: </label>
					<span style="font-size: 1.0em; height: 30px; overflow-wrap:break-word;">${profileViewForm.profileOwner.city}</span><br>
				</c:if>
				<c:if test="${profileViewForm.profileOwner.country != null && profileViewForm.profileOwner.country != ''}">
					<label>Country: </label>
					<span style="font-size: 1.0em; height: 30px; overflow-wrap:break-word;">${profileViewForm.profileOwner.country}</span><br>
				</c:if>
				<label>Interests: </label>
				<c:forEach var="userTag" items="${profileViewForm.profileOwnerTags}">
				<span style="font-size: 0.9em; font-style: oblique; height: 30px; overflow-wrap:break-word;"> ${userTag.tag.tagName}, </span> 
				</c:forEach>
				<c:if test="${not empty profileViewForm.communityList}">
				<br><label>Joined These Communities:</label>
				<c:forEach var="community" items="${profileViewForm.communityList}">
					<span style="font-size: 0.9em; font-style: oblique; height: 30px; overflow-wrap:break-word;">
						<a href="../communities/${community.id}">${community.name} </a>,
					 </span> 
				</c:forEach>
				</c:if>
				<br><label>Email: </label>
				<span style="font-size: 1.0em; height: 30px; overflow-wrap:break-word;">${profileViewForm.profileOwner.email}</span><br>	
				<c:if test="${profileViewForm.profileOwner.info != null}">
					<label>Info: </label>
					<span style="font-size: 1.0em; height: 30px; overflow-wrap:break-word;">${profileViewForm.profileOwner.info}</span><br>	
				</c:if>
				<c:if test="${profileViewForm.profileOwner.mobile != null && profileViewForm.profileOwner.mobile != ''}">
					<br><label>Mobile: </label>
					<span style="font-size: 1.0em; height: 30px; overflow-wrap:break-word;">${profileViewForm.profileOwner.mobile}</span><br>	
				</c:if>
				<c:if test="${profileViewForm.profileOwner.phone != null && profileViewForm.profileOwner.phone != ''}">
					<br><label>Phone: </label>
					<span style="font-size: 1.0em; height: 30px; overflow-wrap:break-word;">${profileViewForm.profileOwner.phone}</span><br>	
				</c:if>	
				</c:if>
				<c:if test="${profileViewForm.profileOwner.id == profileViewForm.profileViewer.id}">
					<div style="margin: 0 29% !important;"class="col-xs-4"><button class="btn btn-lg btn-primary btn-block" onclick="location.href='<spring:url value="/editProfile"></spring:url>'" >Update Profile</button></div>
				</c:if>
				<c:if test="${profileViewForm.profileOwner.id != profileViewForm.profileViewer.id && profileViewForm.friendship == null}">
					<c:choose>
						<c:when test="${profileViewForm.friendshipRequest == null}">
							<div style="margin: 0 29% !important;"class="col-xs-4"><button class="btn btn-lg btn-primary btn-block" onclick="location.href='<spring:url value="/addFriend/${profileViewForm.profileOwner.id}"></spring:url>'" >Add Friend</button></div>
						</c:when>
						<c:otherwise>
							<c:choose>
								<c:when test="${profileViewForm.friendshipRequest.sender.id == profileViewForm.profileViewer.id && 
										profileViewForm.friendshipRequest.receiver.id == profileViewForm.profileOwner.id}">
										<div class="col-xs-12">You sent a friendship request to ${profileViewForm.profileOwner.name}.</div>
										<div style="margin: 0 29% !important;"class="col-xs-4"><button class="btn btn-lg btn-primary btn-block" onclick="location.href='<spring:url value="/cancelFriendshipRequest/${profileViewForm.profileOwner.id}"></spring:url>'" >Cancel Request</button></div>
								</c:when>
								<c:when test="${profileViewForm.friendshipRequest.sender.id == profileViewForm.profileOwner.id && 
										profileViewForm.friendshipRequest.receiver.id == profileViewForm.profileViewer.id}">
									<div class="col-xs-12"> ${profileViewForm.profileOwner.name} sent you a friendship request. </div>
									<div class="col-xs-4"><button class="btn btn-lg btn-primary btn-block" onclick="location.href='<spring:url value="/acceptFriendship/${profileViewForm.profileOwner.id}"></spring:url>'" >Accept</button></div>
									<div class="col-xs-4"><button class="btn btn-lg btn-primary btn-block" onclick="location.href='<spring:url value="/rejectFriendship/${profileViewForm.profileOwner.id}"></spring:url>'" >Reject</button></div>
								</c:when>
							</c:choose>
						</c:otherwise>
					</c:choose>
				</c:if>
				<c:if test="${profileViewForm.profileOwner.id != profileViewForm.profileViewer.id && profileViewForm.friendship != null}">
					<div class="col-xs-12">You are friends with ${profileViewForm.profileOwner.name}.</div>
					<div class="col-xs-4"><button class="btn btn-lg btn-primary btn-block" onclick="location.href='<spring:url value="/unfriend/${profileViewForm.profileOwner.id}"></spring:url>'" >Unfriend</button></div>
				</c:if>
		</div>
		
	</div>
	<%@ include file="/WEB-INF/views/jsp/include/footer.jsp"%>
</body>
</html>